/**
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package ro.uvt.sp.lp.hw1.beermugs.visual;

import java.awt.Dimension;
import java.awt.Graphics;

import javax.swing.JComponent;

/**
 * clasa abstracta pentru desenarea obiectelor ce tin de problema
 * 
 * @author LP
 *
 */
public abstract class Canvas extends JComponent {

	/**
	 * 
	 */
	private static final long serialVersionUID = 5579112984347765679L;
	private State state;
	private State prevState;
	private final State initState;

	private double high = 300;
	private double wide = 450;

	/**
	 * 
	 * @param state
	 * @param initState
	 */
	public Canvas(State state, State initState) {
		this.state = state;
		prevState = state;
		this.initState = initState;
		setVisible(true);
	}

	/**
	 * 
	 * @return
	 */
	public double getPreferredHeight() {
		return high;
	}

	/**
	 * 
	 * @return
	 */
	public double getPreferredWidth() {
		return wide;
	}

	/**
	 * 
	 * @return
	 */
	public State getState() {
		return state;
	}

	/**
	 * 
	 * @param aState
	 */
	public void setState(State aState) {
		this.state = aState;
		makeObjects();

	}

	/**
	 * 
	 * @return
	 */
	public State getPrevState() {
		return prevState;
	}

	/**
	 * 
	 * @param aState
	 */
	public void setPrevState(State aState) {
		prevState = aState;
	}

	/**
	 * 
	 * @return
	 */
	public State getInitState() {
		return initState;
	}

	/**
	 * 
	 */
	@Override
	public Dimension getPreferredSize() {
		return new Dimension((int) wide, (int) high);
	}

	/**
	 * 
	 */
	protected void makeObjects() {
		// must be overridden
	}

	/**
	 * 
	 */
	public void render() {
		// must be overridden
	}

	/**
	     * 
	     */
	@Override
	protected void paintComponent(Graphics g) {
		// must be overridden in subclasses
	}

}
